package com.lmm;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.deepoove.poi.XWPFTemplate;
import com.deepoove.poi.config.Configure;
import com.deepoove.poi.data.RowRenderData;
import com.deepoove.poi.data.Rows;
import com.lmm.config.DocConfig;
import com.lmm.entity.ApiTable;
import com.lmm.entity.DetailData;
import com.lmm.policy.DefaultSelfTableRenderPolicy;
import com.lmm.yapi.*;

import java.io.IOException;
import java.util.*;

/**
 * @Description TODO
 * @Author lmm
 * @Date 2023/10/28 21:25
 */
public class Main {
    public static void main(String[] args) throws IOException {
//        json();
        DocConfig docConfig = getDocConfig();
        List<ApiTable> apiTableList = getApiTableList();
        Configure config = Configure.builder().bind("detail_table", new DefaultSelfTableRenderPolicy()).build();
        XWPFTemplate template = XWPFTemplate.compile(docConfig.getSrcPath(), config);
        template.render(new HashMap<String, Object>() {
            {
                put("item", apiTableList);
            }
        }).writeToFile(docConfig.getOutPath());
    }

    private static ApiTable init() {
        DetailData detailTable = new DetailData();
        RowRenderData good = Rows.of("4", "墙纸", "书房+卧室", "1500").center().create();
        List<RowRenderData> renderData = Arrays.asList(good,good,good);
        RowRenderData labor = Rows.of("油漆工", "2", "200", "400").center().create();
        List<RowRenderData> responseData = Arrays.asList(labor, labor, labor, labor);
        detailTable.setRequest(renderData);
        detailTable.setResponse(responseData);

        ApiTable apiTable = new ApiTable();
        apiTable.setIndex(1);
        apiTable.setApiType("GET");
        apiTable.setName("测试");
        apiTable.setUrl("/lmm/test");
        apiTable.setDetailData(detailTable);
        return apiTable;
    }

    /**
     *  requestParam、paramDetailList转DetailData   todo
     * @param	apiTable
     * @param	requestParam
     * @param	responseParam
     * @return  void
     */
    private static void constructDetailData(ApiTable apiTable, List<ParamDetail> requestParam, List<ParamDetail> responseParam) {
        List<RowRenderData> requestData = new ArrayList<>();
        List<RowRenderData> responseData = new ArrayList<>();
        apiTable.getDetailData().setRequest(requestData);
        apiTable.getDetailData().setResponse(responseData);

        requestParam.forEach(v->{
            requestData.add(Rows.of(v.getDesc(),v.getName(),v.getType(),v.getExample()).center().create());
        });
        responseParam.forEach(v->{
            responseData.add(Rows.of(v.getDesc(),v.getName(),v.getType(),v.getExample()).center().create());
        });

    }

    private static DocConfig getDocConfig(){
        return DocConfig
                .builder()
                .outPath("E:\\out.docx")
                .projectId(1)
                .srcPath("E:\\template.docx")
                .token("asdhjkagdkjahbdkjshadanh")
                .build();
    }

    private static List<ApiTable> getApiTableList(){
        String jsonOfReqBody = "{\n" +
                "    \"errcode\": 0,\n" +
                "    \"errmsg\": \"成功！\",\n" +
                "    \"data\": {\n" +
                "        \"query_path\": {\n" +
                "            \"path\": \"/user/add\",\n" +
                "            \"params\": []\n" +
                "        },\n" +
                "        \"edit_uid\": 0,\n" +
                "        \"status\": \"done\",\n" +
                "        \"type\": \"static\",\n" +
                "        \"req_body_is_json_schema\": true,\n" +
                "        \"res_body_is_json_schema\": true,\n" +
                "        \"api_opened\": false,\n" +
                "        \"index\": 0,\n" +
                "        \"tag\": [],\n" +
                "        \"_id\": 2026,\n" +
                "        \"req_query\": [],\n" +
                "        \"req_headers\": [\n" +
                "            {\n" +
                "                \"required\": \"1\",\n" +
                "                \"_id\": \"650d005907eda823e6c19182\",\n" +
                "                \"name\": \"Content-Type\",\n" +
                "                \"value\": \"application/json\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"title\": \"新增用户记录\",\n" +
                "        \"catid\": 278,\n" +
                "        \"req_body_type\": \"json\",\n" +
                "        \"req_body_other\": \"{\\\"type\\\":\\\"object\\\",\\\"required\\\":[\\\"loginName\\\",\\\"userName\\\",\\\"status\\\"],\\\"title\\\":\\\"SysUser\\\",\\\"description\\\":\\\"SysUser :SysUser\\\",\\\"properties\\\":{\\\"loginName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"用户名\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"userName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"姓名\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"phone\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"电话\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"status\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"状态0：停用，1:启用默认0\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}}}}\",\n" +
                "        \"path\": \"/user/add\",\n" +
                "        \"res_body_type\": \"json\",\n" +
                "        \"res_body\": \"{\\\"type\\\":\\\"object\\\",\\\"title\\\":\\\"empty object\\\",\\\"properties\\\":{}}\",\n" +
                "        \"desc\": \"<pre><code>  /**\\n     * 新增用户记录\\n     */\\n    @PostMapping(\\\"add\\\")\\n    public void add(@RequestBody SysUser user)\\n</code></pre>\\n\",\n" +
                "        \"method\": \"POST\",\n" +
                "        \"req_params\": [],\n" +
                "        \"project_id\": 33,\n" +
                "        \"uid\": 21,\n" +
                "        \"add_time\": 1695281395,\n" +
                "        \"up_time\": 1695350873,\n" +
                "        \"req_body_form\": [],\n" +
                "        \"__v\": 0,\n" +
                "        \"markdown\": \"```\\n  /**\\n     * 新增用户记录\\n     */\\n    @PostMapping(\\\"add\\\")\\n    public void add(@RequestBody SysUser user)\\n```\",\n" +
                "        \"username\": \"lizhongwei\"\n" +
                "    }\n" +
                "} ";
        String json = "{\n" +
                "    \"errcode\": 0,\n" +
                "    \"errmsg\": \"成功！\",\n" +
                "    \"data\": {\n" +
                "        \"query_path\": {\n" +
                "            \"path\": \"/search/recommend\",\n" +
                "            \"params\": []\n" +
                "        },\n" +
                "        \"edit_uid\": 0,\n" +
                "        \"status\": \"done\",\n" +
                "        \"type\": \"static\",\n" +
                "        \"req_body_is_json_schema\": true,\n" +
                "        \"res_body_is_json_schema\": true,\n" +
                "        \"api_opened\": false,\n" +
                "        \"index\": 0,\n" +
                "        \"tag\": [],\n" +
                "        \"_id\": 2000,\n" +
                "        \"req_query\": [\n" +
                "            {\n" +
                "                \"required\": \"1\",\n" +
                "                \"_id\": \"651136e207eda823e6c19245\",\n" +
                "                \"name\": \"keyStr\",\n" +
                "                \"example\": \"String\",\n" +
                "                \"desc\": \"用户输入的关键词(String)\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"req_headers\": [\n" +
                "            {\n" +
                "                \"required\": \"1\",\n" +
                "                \"_id\": \"651136e207eda823e6c19246\",\n" +
                "                \"name\": \"Content-Type\",\n" +
                "                \"value\": \"application/json\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"title\": \"根据keyword 进行相关内容推荐\",\n" +
                "        \"catid\": 274,\n" +
                "        \"req_body_type\": \"json\",\n" +
                "        \"path\": \"/search/recommend\",\n" +
                "        \"res_body_type\": \"json\",\n" +
                "        \"res_body\": \"{\\\"type\\\":\\\"array\\\",\\\"title\\\":\\\"List<SysFileVo>\\\",\\\"description\\\":\\\"List<SysFileVo>\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"文件id\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"fileName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"数据产品名称\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"dirName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"数据目录\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"fileType\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"文件格式\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"fileTypeStr\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"文件格式\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"fileSize\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"文件大小\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"keyWords\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"关键词\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"createUser\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"创建人\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"created\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"创建时间\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@timestamp\\\"}},\\\"secretLevel\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"密级等级\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"secretLevelStr\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"密级等级\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"keyWordList\\\":{\\\"type\\\":\\\"array\\\",\\\"description\\\":\\\"关键词集合 ,String\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"关键词集合\\\"}},\\\"collect\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"0该用户未收藏,1该用户已收藏\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"fileUrl\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"文件预览图\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}}},\\\"required\\\":[]}}\",\n" +
                "        \"desc\": \"<pre><code>  /**\\n     * 根据keyword 进行相关内容推荐\\n     * @param keyStr  用户输入的关键词\\n     */\\n    @GetMapping(\\\"recommend\\\")\\n    public List&lt;SysFileVo&gt; recommend(String keyStr)\\n</code></pre>\\n\",\n" +
                "        \"method\": \"GET\",\n" +
                "        \"req_params\": [],\n" +
                "        \"project_id\": 33,\n" +
                "        \"uid\": 21,\n" +
                "        \"add_time\": 1695280523,\n" +
                "        \"up_time\": 1695626978,\n" +
                "        \"req_body_form\": [],\n" +
                "        \"__v\": 0,\n" +
                "        \"markdown\": \"```\\n  /**\\n     * 根据keyword 进行相关内容推荐\\n     * @param keyStr  用户输入的关键词\\n     */\\n    @GetMapping(\\\"recommend\\\")\\n    public List<SysFileVo> recommend(String keyStr)\\n```\",\n" +
                "        \"username\": \"lizhongwei\"\n" +
                "    }\n" +
                "} ";
        List<ApiTable> res = new ArrayList<>();
        res.add(getApiTable(jsonOfReqBody));
        res.add(getApiTable(json));
        return res;
    }
    private static void json(){
        String jsonOfReqBody = "{\n" +
                "    \"errcode\": 0,\n" +
                "    \"errmsg\": \"成功！\",\n" +
                "    \"data\": {\n" +
                "        \"query_path\": {\n" +
                "            \"path\": \"/user/add\",\n" +
                "            \"params\": []\n" +
                "        },\n" +
                "        \"edit_uid\": 0,\n" +
                "        \"status\": \"done\",\n" +
                "        \"type\": \"static\",\n" +
                "        \"req_body_is_json_schema\": true,\n" +
                "        \"res_body_is_json_schema\": true,\n" +
                "        \"api_opened\": false,\n" +
                "        \"index\": 0,\n" +
                "        \"tag\": [],\n" +
                "        \"_id\": 2026,\n" +
                "        \"req_query\": [],\n" +
                "        \"req_headers\": [\n" +
                "            {\n" +
                "                \"required\": \"1\",\n" +
                "                \"_id\": \"650d005907eda823e6c19182\",\n" +
                "                \"name\": \"Content-Type\",\n" +
                "                \"value\": \"application/json\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"title\": \"新增用户记录\",\n" +
                "        \"catid\": 278,\n" +
                "        \"req_body_type\": \"json\",\n" +
                "        \"req_body_other\": \"{\\\"type\\\":\\\"object\\\",\\\"required\\\":[\\\"loginName\\\",\\\"userName\\\",\\\"status\\\"],\\\"title\\\":\\\"SysUser\\\",\\\"description\\\":\\\"SysUser :SysUser\\\",\\\"properties\\\":{\\\"loginName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"用户名\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"userName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"姓名\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"phone\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"电话\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"status\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"状态0：停用，1:启用默认0\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}}}}\",\n" +
                "        \"path\": \"/user/add\",\n" +
                "        \"res_body_type\": \"json\",\n" +
                "        \"res_body\": \"{\\\"type\\\":\\\"object\\\",\\\"title\\\":\\\"empty object\\\",\\\"properties\\\":{}}\",\n" +
                "        \"desc\": \"<pre><code>  /**\\n     * 新增用户记录\\n     */\\n    @PostMapping(\\\"add\\\")\\n    public void add(@RequestBody SysUser user)\\n</code></pre>\\n\",\n" +
                "        \"method\": \"POST\",\n" +
                "        \"req_params\": [],\n" +
                "        \"project_id\": 33,\n" +
                "        \"uid\": 21,\n" +
                "        \"add_time\": 1695281395,\n" +
                "        \"up_time\": 1695350873,\n" +
                "        \"req_body_form\": [],\n" +
                "        \"__v\": 0,\n" +
                "        \"markdown\": \"```\\n  /**\\n     * 新增用户记录\\n     */\\n    @PostMapping(\\\"add\\\")\\n    public void add(@RequestBody SysUser user)\\n```\",\n" +
                "        \"username\": \"lizhongwei\"\n" +
                "    }\n" +
                "} ";
        String json = "{\n" +
                "    \"errcode\": 0,\n" +
                "    \"errmsg\": \"成功！\",\n" +
                "    \"data\": {\n" +
                "        \"query_path\": {\n" +
                "            \"path\": \"/search/recommend\",\n" +
                "            \"params\": []\n" +
                "        },\n" +
                "        \"edit_uid\": 0,\n" +
                "        \"status\": \"done\",\n" +
                "        \"type\": \"static\",\n" +
                "        \"req_body_is_json_schema\": true,\n" +
                "        \"res_body_is_json_schema\": true,\n" +
                "        \"api_opened\": false,\n" +
                "        \"index\": 0,\n" +
                "        \"tag\": [],\n" +
                "        \"_id\": 2000,\n" +
                "        \"req_query\": [\n" +
                "            {\n" +
                "                \"required\": \"1\",\n" +
                "                \"_id\": \"651136e207eda823e6c19245\",\n" +
                "                \"name\": \"keyStr\",\n" +
                "                \"example\": \"String\",\n" +
                "                \"desc\": \"用户输入的关键词(String)\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"req_headers\": [\n" +
                "            {\n" +
                "                \"required\": \"1\",\n" +
                "                \"_id\": \"651136e207eda823e6c19246\",\n" +
                "                \"name\": \"Content-Type\",\n" +
                "                \"value\": \"application/json\"\n" +
                "            }\n" +
                "        ],\n" +
                "        \"title\": \"根据keyword 进行相关内容推荐\",\n" +
                "        \"catid\": 274,\n" +
                "        \"req_body_type\": \"json\",\n" +
                "        \"path\": \"/search/recommend\",\n" +
                "        \"res_body_type\": \"json\",\n" +
                "        \"res_body\": \"{\\\"type\\\":\\\"array\\\",\\\"title\\\":\\\"List<SysFileVo>\\\",\\\"description\\\":\\\"List<SysFileVo>\\\",\\\"items\\\":{\\\"type\\\":\\\"object\\\",\\\"properties\\\":{\\\"id\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"文件id\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"fileName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"数据产品名称\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"dirName\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"数据目录\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"fileType\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"文件格式\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"fileTypeStr\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"文件格式\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"fileSize\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"文件大小\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"keyWords\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"关键词\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"createUser\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"创建人\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"created\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"创建时间\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@timestamp\\\"}},\\\"secretLevel\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"密级等级\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"secretLevelStr\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"密级等级\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}},\\\"keyWordList\\\":{\\\"type\\\":\\\"array\\\",\\\"description\\\":\\\"关键词集合 ,String\\\",\\\"items\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"关键词集合\\\"}},\\\"collect\\\":{\\\"type\\\":\\\"number\\\",\\\"description\\\":\\\"0该用户未收藏,1该用户已收藏\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@integer\\\"}},\\\"fileUrl\\\":{\\\"type\\\":\\\"string\\\",\\\"description\\\":\\\"文件预览图\\\",\\\"mock\\\":{\\\"mock\\\":\\\"@string\\\"}}},\\\"required\\\":[]}}\",\n" +
                "        \"desc\": \"<pre><code>  /**\\n     * 根据keyword 进行相关内容推荐\\n     * @param keyStr  用户输入的关键词\\n     */\\n    @GetMapping(\\\"recommend\\\")\\n    public List&lt;SysFileVo&gt; recommend(String keyStr)\\n</code></pre>\\n\",\n" +
                "        \"method\": \"GET\",\n" +
                "        \"req_params\": [],\n" +
                "        \"project_id\": 33,\n" +
                "        \"uid\": 21,\n" +
                "        \"add_time\": 1695280523,\n" +
                "        \"up_time\": 1695626978,\n" +
                "        \"req_body_form\": [],\n" +
                "        \"__v\": 0,\n" +
                "        \"markdown\": \"```\\n  /**\\n     * 根据keyword 进行相关内容推荐\\n     * @param keyStr  用户输入的关键词\\n     */\\n    @GetMapping(\\\"recommend\\\")\\n    public List<SysFileVo> recommend(String keyStr)\\n```\",\n" +
                "        \"username\": \"lizhongwei\"\n" +
                "    }\n" +
                "} ";

        Res res;
        res = JSONUtil.toBean(json, Res.class);
        System.out.println(res);
        JSONObject jsonObject = (JSONObject)res.getData();

        // 处理请求 or 请求体数据
        List<ParamDetail> requestParam = new ArrayList<>();
        dealRequest(jsonObject,requestParam);
        // 处理响应体数据
        List<ParamDetail> paramDetailList = dealResBody((String)jsonObject.get("res_body"));

        ApiTable apiTable = new ApiTable();
        apiTable.setApiType((String)jsonObject.get("method"));
        apiTable.setUrl((String)jsonObject.get("path"));
        apiTable.setIndex(1);
        apiTable.setName((String)jsonObject.get("title"));
        apiTable.setDetailData(new DetailData());
        constructDetailData(apiTable,requestParam,paramDetailList);

    }
    private static ApiTable getApiTable(String apiJson){
        if (StrUtil.isBlank(apiJson))
            return null;
        Res res;
        res = JSONUtil.toBean(apiJson, Res.class);
        System.out.println(res);
        JSONObject jsonObject = (JSONObject)res.getData();

        // 处理请求 or 请求体数据
        List<ParamDetail> requestParam = new ArrayList<>();
        dealRequest(jsonObject,requestParam);
        // 处理响应体数据
        List<ParamDetail> paramDetailList = dealResBody((String)jsonObject.get("res_body"));

        ApiTable apiTable = new ApiTable();
        apiTable.setApiType((String)jsonObject.get("method"));
        apiTable.setUrl((String)jsonObject.get("path"));
        apiTable.setIndex(1);
        apiTable.setName((String)jsonObject.get("title"));
        apiTable.setDetailData(new DetailData());
        constructDetailData(apiTable,requestParam,paramDetailList);
        return apiTable;
    }


    private static void dealRequest(JSONObject jsonObject, List<ParamDetail> requestParam) {
        if (Objects.isNull(jsonObject))
            return;
        JSONArray query = (JSONArray)jsonObject.get("req_query");
        if (Objects.isNull(query) || query.size() == 0){
            // 请求体
            JSONObject req_body_other = JSONUtil.toBean((String) jsonObject.get("req_body_other"), JSONObject.class);
            if (Objects.isNull(req_body_other))
                return;
            circleDoParse(requestParam,req_body_other,null);
        }else {
            for (Object o : query) {
                JSONObject item = (JSONObject) o;
                requestParam.add(ParamDetail
                        .builder()
                        .name((String) item.get("name"))
                        .type((String) item.get("example"))
                        .desc((String) item.get("desc"))
                        .build()
                );
            }
        }
    }

    /**
     * 处理接口详情
     * @param	collect
     * @param	jsonObject
     * @param	key
     * @return  void
    */
    private static void circleDoParse(List<ParamDetail> collect,JSONObject jsonObject,String key){
        if (Objects.isNull(jsonObject))
            return;
        String type = (String)jsonObject.get("type");
        if (StrUtil.isBlank(type))
            return;
        if (TypeEnum.ARRAY.getDes().equals(type)){
            collect.add(ParamDetail
                    .builder()
                            .desc((String)jsonObject.get("description"))
                            .example((String)jsonObject.get("description"))
                            .name((String)jsonObject.get("title"))
                            .type(type)
                    .build()
            );
            circleDoParse(collect,(JSONObject)jsonObject.get(TypeEnum.ARRAY.getProperties()),null);
        }else if (TypeEnum.OBJECT.getDes().equals(type)){
            JSONObject properites = (JSONObject)jsonObject.get(TypeEnum.OBJECT.getProperties());
            for (Map.Entry<String, Object> properite : properites) {
                circleDoParse(collect,(JSONObject) properite.getValue(),properite.getKey());
            }
        }else {
            collect.add(ParamDetail
                    .builder()
                    .desc((String)jsonObject.get("description"))
                    .example((String)jsonObject.get("description"))
                    .name(key)
                    .type(type)
                    .build()
            );
        }
    }
    /**
     * 解析响应体json数据
     * @param	res_body
     * @return  java.util.List<com.lmm.yapi.ParamDetail>
    */
    private static List<ParamDetail> dealResBody(String res_body){
        if (StrUtil.isBlank(res_body))
            return new ArrayList<>();
        // 处理响应体数据
        JSONObject resBodyItem = (JSONObject)JSONUtil.toBean(res_body, Object.class);
        List<ParamDetail> paramDetailList = new ArrayList<>();
        circleDoParse(paramDetailList,resBodyItem,null);
        return paramDetailList;
    }


}
